package web.Servlet;

import Service.yuliangService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "updateServlet",urlPatterns = "/xg")
public class updateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String qys = req.getParameter("qys");
        String times = req.getParameter("times");
        String yls = req.getParameter("yls");
        String jcs = req.getParameter("jcs");
        String zds = req.getParameter("zds");
        String id = req.getParameter("id");
        ArrayList arrayList = new ArrayList();
        arrayList.add(qys);
        arrayList.add(times);
        arrayList.add(yls);
        arrayList.add(jcs);
        arrayList.add(zds);
        arrayList.add(id);
        yuliangService yuliangService = new yuliangService();
        int update = yuliangService.update(arrayList);
        if(update>0){
            req.getRequestDispatcher("/yl").forward(req,resp);
        }else {
            resp.getWriter().append("修改失败");
        }
    }
}
